package com.inno.launcher.presenter;

import com.inno.launcher.api.MarketApi;
import com.inno.launcher.base_rebuild.BaseEntity;
import com.inno.launcher.bean.TestBean;
import com.inno.launcher.contract.MainContract;
import com.inno.launcher.https_rebuild.HttpManager;
import com.inno.launcher.impl_rebuild.HttpOnNextListener;
import com.trello.rxlifecycle.components.support.RxAppCompatActivity;

/**
 * @author (zijie)
 * @datetime 2021-10-27 17:40
 * @email hezijie@inno-cn.cn
 * @detali：
 */
public class MainPresenter implements MainContract.Presenter {
    private MainContract.View view;

    public MainPresenter(MainContract.View view) {
        this.view = view;
    }

    @Override
    public void getMarketList(RxAppCompatActivity rxAppCompatActivity, String category, String pageSize, int pageNum, String state) {
        MarketApi marketApi = new MarketApi(rxAppCompatActivity);
        marketApi.setCategory(category);
        marketApi.setPageSize(pageSize);
        marketApi.setPageNum(pageNum);
        marketApi.setState(state);
        marketApi.setListener(new HttpOnNextListener<BaseEntity<TestBean>>() {
            @Override
            public void onNext(BaseEntity<TestBean> baseEntity) {
                view.getMarketList(baseEntity);
            }
        });

        HttpManager.getInstance().doHttpDeal(rxAppCompatActivity,marketApi);
    }
}
